import json

# 将json数组 数据写入到新的json文件里面

# 指定输入文件路径
input_file_path = 'D:\\PythonWorks\\pythonlearning\\01test\\tiantianjijin\\all_processed_data.json'
output_file_path = 'D:\\PythonWorks\\pythonlearning\\01test\\tiantianjijin\\diff_data.json'
# 指定输出文件路径

# input_file_path = '/Users/macbookair/workspace/pythonlearning/01test/tiantianjijin/all_processed_data.json'
# output_file_path = '/Users/macbookair/workspace/pythonlearning/01test/tiantianjijin/diff_data.json'

# 读取输入文件中的 JSON 数据
with open(input_file_path, 'r', encoding='utf-8') as f:
    all_data = json.load(f)

# 提取所有 diff 数据
diff_data = []
for item in all_data:
    if 'data' in item and 'diff' in item['data']:
        diff_data.extend(item['data']['diff'])

# 将所有的 diff 数据写入输出文件中
with open(output_file_path, 'w', encoding='utf-8') as f:
    json.dump(diff_data, f, ensure_ascii=False)

print(f"数据已保存到文件 {output_file_path}")
